﻿using System;
using System.Collections.Generic;
using System.Web.Mvc;
using System.Web.Routing;
using MvcExtensions;

namespace mForum.Web.Core
{
    using mForum.Core.Common;

    public class RegisterRoutes : RegisterRoutesBase
    {
        protected override void Register(RouteCollection routes)
        {
            Check.Argument.IsNotNull(routes, "routes");

            routes.IgnoreRoute("{file}.js");
            // Ignore text, html, xml files.
            routes.IgnoreRoute("{file}.txt");
            routes.IgnoreRoute("{file}.htm");
            routes.IgnoreRoute("{file}.html");
            routes.IgnoreRoute("{file}.xml");
            // Ignore axd files such as assest, image, sitemap etc
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            // Ignore the assets directory which contains images, js, css & html
            routes.IgnoreRoute("Content/{*pathInfo}");
            routes.IgnoreRoute("Scripts/{*pathInfo}");
            // Ignore the error directory which contains error pages
            routes.IgnoreRoute("ErrorPages/{*pathInfo}");
            // Ignore the ado.net data services directory which contains data services
            routes.IgnoreRoute("DataServices/{*pathInfo}");
            //Exclude favicon (google toolbar request gif file as fav icon)
            routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.([iI][cC][oO]|[gG][iI][fF])(/.*)?" });

            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
            );

            AreaRegistration.RegisterAllAreas();
        }
    }
}
